"""
LogWisdomHub URL Configuration

主URL配置文件，定义了所有API路由

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.routers import DefaultRouter
from rest_framework.documentation import include_docs_urls

# 创建API路由器
router = DefaultRouter()

# API URL模式
urlpatterns = [
    # Django管理后台
    path('admin/', admin.site.urls),
    
    # API根路径
    path('api/', include([
        # 用户认证相关API
        path('accounts/', include('accounts.urls')),
        
        # 项目管理API
        path('projects/', include('projects.urls')),
        
        # 日志管理API
        path('logs/', include('logs.urls')),
        
        # DRF路由器注册的API
        path('', include(router.urls)),
    ])),
    
    # API文档（开发环境）- 临时注释掉，避免coreapi依赖问题
    # path('docs/', include_docs_urls(title='LogWisdomHub API')),
    
    # DRF认证页面
    path('api-auth/', include('rest_framework.urls')),
]

# 开发环境静态文件服务
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)